package com.ybkj.o2o.sales.service.impl;

import com.ybkj.o2o.sales.entity.ActivityRecord;
import com.ybkj.o2o.sales.mapper.ActivityRecordMapper;
import com.ybkj.o2o.sales.service.ActivityRecordService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;


@Service
public class DefaultActivityRecordService implements ActivityRecordService {

  @Autowired
  private ActivityRecordMapper activityRecordMapper;

  @Override
  public ActivityRecord findOne(Long recordId, String appKey) {
    return activityRecordMapper.selectByPrimaryKey(recordId, appKey);
  }

  /**
   * 事务回滚.
   */
  @Transactional(rollbackFor = Exception.class)
  public Long insert(ActivityRecord activityRecord) {

    return activityRecordMapper.insertRecord(activityRecord);

  }

  @Override
  public Long countByActivityAndPassenger(Long activityId, Long passengerId, String appKey) {

    return activityRecordMapper.countByActivityAndPassenger(activityId, passengerId, appKey);
  }

  @Override
  public List<ActivityRecord> queryByActivity(Long activityId, Long companyId, String phone,
      Date startTime, Date endTime, Integer offset, Integer size, String appKey) {

    return activityRecordMapper.selectByActivity(activityId, companyId, phone, startTime, endTime,
        offset, size, appKey);
  }

  @Override
  public long countByActivity(Long activityId, Long companyId, String phone, Date startTime,
      Date endTime, String appKey) {

    return activityRecordMapper.countByActivity(activityId, companyId, phone, startTime, endTime,
        appKey);
  }


}
